#include<stdio.h>
int main()

{
    int a[1000]={-1};
    int b[1000]={-1};
    int counta=0,countb=0,i=0,j=0,countb1=0;
    do
    {
        scanf("%d",&a[i]);
    } while(a[i++]!=-1);
    counta=i;
    i=0;
    do 
    {
        scanf("%d",&b[i]);
    } while(b[i++]!=-1);
    countb=i;
    for(i=0;i<counta;i++)
    {
        if(a[i]==b[j])
        {
            for(int k=i;j<countb&&k<counta;j++,k++)
            {
                if(a[k]!=b[j]) break;
            }
            if(countb1<j) countb1=j;
            j=0;
        }
    }
    if(countb==countb1) printf("ListB is the sub sequence of ListA.");
    else printf("ListB is not the sub sequence of ListA.");
    return 0;
}